import { IFeidaoAiNodejsComponent } from '@feidao/web/interfaces';
import P02 from './P02';
import P04 from './P04';
import nodejs from '@feidao/web/atom/nodejs/msg-b/nodejs';
import server_render from '../atom/server-render';

export default async function (fd: IFeidaoAiNodejsComponent, ...args: any[]) {

	const param = {
		criteria: fd.data.params.criteria,
		page_size: 0,
		page_no: 1,
		asc: ['teacher_no']
	};
	const res = await nodejs('flippedclass', 'usable-exam-teacher-find', param);

	if (res.count === 0) {
		server_render(fd.data.node, 'P02', P02, []);
		server_render(fd.data.node, 'P04', P04, []);
	} else {
		server_render(fd.data.node, 'P02', P02, res.dataArray);
	}
}